package com.cos.service.system.appuser;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cos.dao.DaoSupport;
import com.cos.entity.Page;
import com.cos.entity.system.User;
import com.cos.util.PageData;


@Service("appuserService")
public class AppuserService {

	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	//======================================================================================
	
	/*
	* 通过id获取数据
	*/
	public PageData findByUiId(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppuserMapper.findByUiId", pd);
	}
	/*
	* 通过loginname获取数据
	*/
	public PageData findByUId(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppuserMapper.findByUId", pd);
	}
	
	/*
	* 通过邮箱获取数据
	*/
	public PageData findByUE(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppuserMapper.findByUE", pd);
	}
	
	/*
	* 通过编号获取数据
	*/
	public PageData findByUN(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppuserMapper.findByUN", pd);
	}
	
	/*
	* 保存用户
	*/
	public void saveU(PageData pd)throws Exception{
		dao.save("AppuserMapper.saveU", pd);
	}
	/*
	* 修改用户
	*/
	public void editU(PageData pd)throws Exception{
		dao.update("AppuserMapper.editU", pd);
	}
	/*
	* 删除用户
	*/
	public void deleteU(PageData pd)throws Exception{
		dao.delete("AppuserMapper.deleteU", pd);
	}
	/*
	* 批量删除用户
	*/
	public void deleteAllU(String[] USER_IDS)throws Exception{
		dao.delete("AppuserMapper.deleteAllU", USER_IDS);
	}
	/*
	*用户列表(全部)
	*/
	@SuppressWarnings("unchecked")
	public List<PageData> listAllUser(PageData pd)throws Exception{
		return (List<PageData>) dao.findForList("AppuserMapper.listAllUser", pd);
	}
	
	/*
	*用户列表(用户组)
	*/
	@SuppressWarnings("unchecked")
	public List<PageData> listPdPageUser(Page page)throws Exception{
		return (List<PageData>) dao.findForList("AppuserMapper.userlistPage", page);
	}
	
	/*
	* 保存用户IP
	*/
	public void saveIP(PageData pd)throws Exception{
		dao.update("AppuserMapper.saveIP", pd);
	}
	
	/*
	* 登录判断
	*/
	public PageData getUserByNameAndPwd(PageData pd)throws Exception{
		return (PageData)dao.findForObject("AppuserMapper.getUserInfo", pd);
	}
	/*
	* 跟新登录时间
	*/
	public void updateLastLogin(PageData pd)throws Exception{
		dao.update("AppuserMapper.updateLastLogin", pd);
	}
	//======================================================================================
	
	/**
	 * 根据用户ID 查询用户所有的组别
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getGroup(PageData pd) throws Exception{
		return (List<PageData>) dao.findForList("AppuserMapper.getGroup", pd);
	}
	/**
	 * 根据组的ID查询出下面的用户
	 * @param group_ID
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getUserByGroupID(String group_ID) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getUserByGroupID", group_ID);
	}
	
	/**
	 * 获取用户的公司列表
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getCompany(PageData pd) throws Exception {
		return  (List<PageData>) dao.findForList("AppuserMapper.getCompany", pd);
	}
	
	/**
	 * 获取部门
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getDepartment(PageData pd) throws Exception {
		return  (List<PageData>) dao.findForList("AppuserMapper.getDepartment", pd);
	}
	
	/**
	 * 获取工作分工
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getWordAdvice(PageData pd) throws Exception {
		return  (List<PageData>) dao.findForList("AppuserMapper.getWordAdvice", pd);
	}
	/**
	 * 获取备忘录标签
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getMemoryTag(PageData pd) throws Exception {
		return  (List<PageData>) dao.findForList("AppuserMapper.getMemoryTag", pd);
	}
	/**
	 * 获取备忘录
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getMemory(PageData pd) throws Exception {
		return   (List<PageData>) dao.findForList("AppuserMapper.getMemory", pd);
	}
	
	/**
	 * 获取收藏
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getCollection(PageData pd) throws Exception {
		return   (List<PageData>) dao.findForList("AppuserMapper.getCollection", pd);
	}
	
	
	/**
	 * 得到通讯录组
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getNoteGroup(PageData pd) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getNoteGroup", pd);
	}
	/**
	 * 通过通讯录的组获取用户
	 * @param group_ID
	 * @return
	 * @throws Exception 
	 */
	public List<PageData> getUserByNoteGroupID(String group_ID) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getUserByNoteGroupID", group_ID);
	}
	
	
	/**
	 * 取出父类的部门
	 * @param pd  公司ID
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getDepartmentParent(PageData pd) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getDepartmentParent", pd);
	}
	
	
	/**
	 * 根据父类部门取出下面的子部门
	 * @param parentId父类部门的ID
	 * @return 
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getDepartmentByParentID(String parentId) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getDepartmentByParentID", parentId);
	}
	
	/**
	 * 根据部门ID取出下面的用户
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getUserListByDepartmentID(String DID) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getUserListByDepartmentID", DID);
	}
	
	/**
	 * 判断新增的用户在数据库中是否有一样的用户名
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	public int isExistUsername(PageData pd) throws Exception {
		return (int)dao.findForObject("AppuserMapper.isExistUsername", pd);
	}
	
	/**
	 * 通过部门ID取出这个部门的基本信息
	 * @param departmentID
	 * @return
	 * @throws Exception 
	 */
	public PageData getDepart(String D_ID) throws Exception {
		return (PageData)dao.findForObject("AppuserMapper.getDepart", D_ID);
	}
	public PageData getDepartTest(String PARENT_ID) throws Exception {
		return (PageData)dao.findForObject("AppuserMapper.getDepartTest", PARENT_ID);
	}
	
	/**
	 * 往手机验证码表增加一条数据
	 * @param pd
	 * @throws Exception 
	 */
	public void insertToPhoneCode(PageData pd) throws Exception {
		dao.save("AppuserMapper.insertToPhoneCode", pd);
	}
	public PageData getPhoneCode(PageData pd) throws Exception {
		return (PageData)dao.findForObject("AppuserMapper.getPhoneCode", pd);
	}
	
	
	/**
	 * 获取工作提议详情
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public PageData getWordAdviceDetail(PageData pd) throws Exception {
		return (PageData)dao.findForObject("AppuserMapper.getWordAdviceDetail", pd);
	}
	
	/**
	 * 获取工作自荐列表
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getWorkRecommend(PageData pd) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getWorkRecommend", pd);
	}
	
	/**
	 * 获取评论
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getComment(PageData pd) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getComment", pd);
	}
	
	/**
	 * 获取回复列表
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getReply(PageData pd) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getReply", pd);
	}
	/**
	 * 获取赞 踩的人
	 * @param pd
	 * @return
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public List<PageData> getDynamicStatus(PageData pd) throws Exception {
		return (List<PageData>) dao.findForList("AppuserMapper.getDynamicStatus", pd);
	}
	
	/**发布工作提议
	 * @param pd
	 * @throws Exception 
	 */
	public void saveWordAdvice(PageData pd) throws Exception {
		dao.save("AppuserMapper.saveWordAdvice", pd);
	}
	
	/**
	 * @param pd
	 * @throws Exception 
	 */
	public void saveMemoryTag(PageData pd) throws Exception {
		dao.save("AppuserMapper.saveMemoryTag", pd);
	}
	
	
	/**
	 * 新增备忘录
	 * @param pd
	 * @throws Exception 
	 */
	public void saveMemory(PageData pd) throws Exception {
		dao.save("AppuserMapper.saveMemory", pd);
	}
	
	/**
	 * 新增工作自荐
	 * @param pd
	 * @throws Exception
	 */
	public void saveWorkRecommend(PageData pd) throws Exception {
		dao.save("AppuserMapper.saveWorkRecommend", pd);
	}
	public void updateUserlogo(PageData pd) throws Exception {
		dao.save("AppuserMapper.updateUserlogo",pd);
	}

	
}

